﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace blackhouse.StareKino.Web.Events {
    public class PostImagePhoto : Control {

        #region Fields

        private CinemaPostModel postModel;

        #endregion

        #region Methods

        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);

            this.postModel = new CinemaPostModel();
        }

        protected override void Render(HtmlTextWriter writer) {
            string photoSrc = this.postModel.Post.GetPhotoUrl();
            if (!String.IsNullOrEmpty(photoSrc)) {
                writer.AddAttribute(HtmlTextWriterAttribute.Src, photoSrc);
                writer.AddAttribute(HtmlTextWriterAttribute.Alt, this.postModel.Post.Title);
                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                writer.RenderEndTag();
            }
        }

        #endregion

    }
}